<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jstl/core"
                xmlns:sf="http://www.springframework.org/tags/faces"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:spring="http://www.springframework.org/tags"
                template="../../../layout/Template.xhtml">

    <ui:define name="menu">
        <ui:include src="${user.menu}"/>
    </ui:define>

    <ui:define name="title">
        <h:outputText value="#{resourceBundle.createCourseWelcome}"/>
    </ui:define>

    <ui:define name="footer">
        <h:outputText value="SPiJ - Universite de Marne la Vallee - Version 1.0"/>
    </ui:define>

    <ui:define name="content">

        <ui:fragment id="createTrainingFragment">
            <h:messages globalOnly="true"/>

            <rich:panel id="createTrainingPanel" header="#{resourceBundle.createCourseWelcome}">
                <h:form id="createTrainingForm">
                    <h:panelGrid id="createTrainingGrid" columns="3">

                        <h:outputText value="#{resourceBundle.createCourseFormName} : "/>
                        <h:inputText value="#{viewScope.createdCourse.name}"
                                     id="createTrainingInputName" required="true"
                                     requiredMessage="#{resourceBundle.createCourseRequiredMessageName}"/>
                        <h:message for="createTrainingInputName" style="color:red;"/>

                        <h:outputText value="#{resourceBundle.createCourseFormNbMatter} : "/>
                        <h:inputText value="#{viewScope.createdCourse.nbMatter}"
                                     id="createTrainigInputNbYear" required="true"
                                     requiredMessage="#{resourceBundle.createCourseRequiredMessageNbMatter}"/>
                        <h:message for="createTrainigInputNbYear" style="color:red;"/>

                        <h:panelGrid id="validateRegistrationGrid" columns="2">

                            <h:outputText
                                    value="#{resourceBundle.obligatoryUnitList} : "/>
                            <h:outputText/>

                            <rich:pickList value="#{viewScope.createdCourse.obligatoryUnits}" id="units"
                                           copyAllVisible="false" removeAllVisible="false">
                                <f:selectItems value="#{flowScope.listUnit}"/>
                                <a4j:support event="onlistchanged" reRender="result"/>
                            </rich:pickList>
                            <h:message for="units" style="color:red"/>

                        </h:panelGrid>

                    </h:panelGrid>
                    
                    <h:panelGrid id="validateRegistrationGrid2" columns="2">

                            <h:outputText
                                    value="#{resourceBundle.optionalUnitList} : "/>
                            <h:outputText/>

                            <rich:pickList value="#{viewScope.createdCourse.optionalUnits}" id="optionalUnits"
                                           copyAllVisible="false" removeAllVisible="false">
                                <f:selectItems value="#{flowScope.listUnit}"/>
                                <a4j:support event="onlistchanged" reRender="result"/>
                            </rich:pickList>
                            <h:message for="optionalUnits" style="color:red"/>

                    </h:panelGrid>

                    <a4j:commandButton type="submit"
                                       value="#{bundle.addButton}" action="add"/>
                    <a4j:commandButton value="#{bundle.cancelButton}" action="cancel"
                                       immediate="true"/>
                </h:form>
            </rich:panel>
        </ui:fragment>
    </ui:define>

</ui:composition>